import com.fasterxml.jackson.databind.ObjectMapper;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;

class Score{
    public ArrayList<Integer> scores;
}
class Student{
    public int studentId;
    public String studentName;
    public Score score;
}
@WebServlet("/json")
public class JsonServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ObjectMapper objectMapper = new ObjectMapper();
        Student s = objectMapper.readValue(req.getInputStream(), Student.class);
        System.out.println(s.studentId);
        System.out.println(s.studentName);
//        resp.setContentType("text/html;charset=utf-8");
//        resp.getWriter().write(s.studentId+","+s.studentName);
        resp.setContentType("application/json;charset=utf-8");
        resp.getWriter().write(objectMapper.writeValueAsString(s));
    }
}
